<?php


namespace App\Http\Middleware;


use App\Exceptions\BusinessException;
use App\Helpers\CodeResponse;
use Closure;
use Illuminate\Auth\Middleware\Authenticate as Middleware;

class AdminEnableStatus extends Middleware {

    public function handle($request, Closure $next, ...$guards) {
        $admin = $this->auth->guard('admin')->user();

        if ($admin && !$admin->enable_status) {
            throw new BusinessException(CodeResponse::ACCOUNT_IS_DISABLED);
        }

        return $next($request);
    }
}
